home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Camelot
/
Camelot 134 (1991-10)(Swedish User Group of Amiga)(SE)(PD)[WB].zip
/
Camelot 134 (1991-10)(Swedish User Group of Amiga)(SE)(PD)[WB].adf
/
RxSlides
/
RxSlides.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-08
|
8KB
|
414 lines
/* :bk=0 */
/****************************************************************/
/* */
/* RxSlides.c */
/* */
/* Author: Dean Bandes */
/* */
/* Based on Lee M. Robertson's "Dissolve" on Amicus 15 */
/* which is in turn based on an article in the Nov '86 */
/* Doctor Dobb's Journal by Mike Morton */
/* */
/****************************************************************/
#include "exec/types.h"
#include "exec/memory.h"
#include "storage.h"
#include "rxslib.h"
#include <stdio.h>
#include <ctype.h>
#include "rxslides.h"
#define INTUITION_REV 29L
#define GRAPHICS_REV 29L
struct MsgPort *CreatePort ();
struct MsgPort *FindPort ();
void *GetMsg();
void *OpenLibrary();
ULONG ctlcbit = 0x1000;
LONG debug_level = 21;
LONG failat = 21;
char filename[80] = "";
struct GfxBase *GfxBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;
BOOL keep_going = TRUE;
ULONG rexbit = 0;
SHORT rmap_index = 16;
struct RexxLib *RexxSysBase = NULL;
struct MsgPort *Rxpt = NULL;
LONG speed = 1280;
SHORT transition = 0;
#ifndef DEBUG
LONG _stack = 4000;
char *_procname = "RXSLIDES";
LONG _priority = 0;
LONG _BackGroundIO = 0;
/*-h- void _main ()
*/
void _main ()
#else
/*-h- void main ()
*/
void main(argc,argv)
int argc;
char **argv;
#endif
{
extern void close_libs ();
extern void CloseReXXPort ();
#ifdef DEBUG
extern int get_args ();
#endif
extern int open_libs();
extern int OpenReXXPort ();
struct RexxMsg *rmsg = NULL;
ULONG signal = 0;
int status;
#ifdef DEBUG
status = get_args (argc, argv);
if (status != STS_OK)
exit (STS_BAD_ARGS);
if ( debug_level > 9 )
printf ("Returned from get_args\n");
#endif
if( speed < 100 )
speed = 1000;
status = open_libs(); /* open the libraries */
if (status != STS_OK)
exit (STS_BAD_LIBS);
status = OpenReXXPort ();
if ( status != STS_OK )
{
close_libs ();
exit (STS_NO_PORT);
}
while (keep_going && (status < failat))
{
if ( debug_level > 10 )
signal = (ULONG) Wait (0xffffffff);
else
signal = (ULONG) Wait (ctlcbit | rexbit );
#ifdef DEBUG
if ( debug_level > 5 )
printf ("Received signal %8lx\n", signal);
#endif
if ( signal & ctlcbit )
{
#ifdef DEBUG
if ( debug_level > 5 )
printf ("Looks like a ctrl-C, bye...\n");
#endif
keep_going = FALSE;
break;
}
if ( signal & rexbit )
{
while (rmsg = (struct RexxMsg *) GetMsg (Rxpt))
{
#ifdef DEBUG
if (debug_level > 15)
printf (" rexx msg pointer = 0x%08lx\n", rmsg);
if (debug_level > 1)
printf ("Rexx: %s\n", rmsg->rm_Args[0]);
#endif
status = Dissolve_dispatch (rmsg->rm_Args[0]);
#ifdef DEBUG
if (debug_level > 15)
printf (" replying, rexx msg pointer = 0x%08lx, status %d\n",
rmsg,
status);
#endif
rmsg->rm_Result1 = status;
ReplyMsg (rmsg);
rmsg = NULL;
}
}
}
CloseReXXPort ();
close_pic_window ();
close_libs ();
exit (STS_OK);
}
/*-h- OpenReXXPort ()
*
* Open the message port for ReXX communication
*
* Returns a status (0 = OK)
*/
int OpenReXXPort ()
{
static char portname[12];
int portnum = 0;
#ifdef DEBUG
if ( debug_level > 9 )
printf ("Entered OpenReXXPort\n");
#endif
strcpy (portname, "SLIDES");
#ifdef DEBUG
if ( debug_level > 9 )
printf ("Trying message port name = %s\n", portname);
#endif
while (Rxpt = FindPort (portname))
{
if ( portnum > 26 )
{
#ifdef DEBUG
if ( debug_level > 1 )
printf ("Ports SLIDES thru SLIDESZ in use\n");
#endif
Rxpt = 0;
return (STS_NO_PORT);
}
portname[6] = 'A' + portnum++;
portname[7] = '\0';
#ifdef DEBUG
if ( debug_level > 9 )
printf ("Trying message port name = %s\n", portname);
#endif
}
Rxpt = CreatePort (portname, 0);
if ( Rxpt )
{
rexbit = 1 << Rxpt->mp_SigBit;
#ifdef DEBUG
if ( debug_level > 1 )
{
printf ("Opened message port %s\n", portname);
printf (" signal bit = %d\n", Rxpt->mp_SigBit);
printf (" signal flag = %8lx\n", rexbit);
}
#endif
return (STS_OK);
}
else
{
#ifdef DEBUG
if ( debug_level > 1 )
printf ("CreatePort failed\n");
#endif
return (STS_NO_PORT);
}
}
/*-h- void CloseReXXPort
*
* Empties the ReXX port message queue and closes the port
*/
void CloseReXXPort ()
{
struct RexxMsg *rmsg = NULL;
while (rmsg = (struct RexxMsg *) GetMsg (Rxpt))
{
rmsg->rm_Result1 = STS_CLEANING_UP;
ReplyMsg (rmsg);
rmsg = 0;
}
DeletePort (Rxpt);
}
/*-h- int open_libs ()
*
* open the required libraries
*
* Returns status code (0 = OK)
*/
int open_libs()
{
if( !(IntuitionBase = (struct IntuitionBase *)
OpenLibrary("intuition.library",INTUITION_REV)) )
{
#ifdef DEBUG
printf("Can't open Intuition library\n");
#endif
return(STS_BAD_LIBS);
}
if( !(GfxBase = (struct GfxBase *)
OpenLibrary("graphics.library",GRAPHICS_REV)) )
{
#ifdef DEBUG
printf("Can't open Graphics library\n");
#endif
CloseLibrary(IntuitionBase);
return(STS_BAD_LIBS);
}
if ( !(RexxSysBase = (struct RexxLib *)
OpenLibrary("rexxsyslib.library",(LONG) RXSVERS)) )
{
#ifdef DEBUG
printf("Can't open Rexx library\n");
#endif
CloseLibrary(GfxBase);
CloseLibrary(IntuitionBase);
return(STS_BAD_LIBS);
}
return (STS_OK);
}
/*-h- void close_libs ()
*/
void close_libs ()
{
if( GfxBase )
CloseLibrary(GfxBase);
if( IntuitionBase )
CloseLibrary(IntuitionBase);
if( RexxSysBase )
CloseLibrary(RexxSysBase);
}
/*-h- int Dissolve_dispatch (rxcommand)
*
* char *rxcommand command line received from ReXX
*/
int Dissolve_dispatch (rxcommand)
char *rxcommand;
{
char *command;
char *str2;
int status = STS_OK;
int delay_param = 0;
char cbuff[128];
char pbuff[128];
#ifdef DEBUG
if ( debug_level > 15 )
printf ("Entered Dissolve_dispatch with command %s\n", rxcommand);
#endif
command = rxcommand;
str2 = cbuff;
*str2 = '\0';
while (*command && isspace (*command))
command++;
while (*command && ( ! isspace (*command)))
*str2++ = *command++;
*str2 = '\0';
str2 = pbuff;
*str2 = '\0';
while (*command && isspace (*command))
command++;
while (*command && ( ! isspace (*command)))
*str2++ = *command++;
*str2 = '\0';
#ifdef DEBUG
if (debug_level > 15 )
printf ("Parsed as command %s, parameter %s\n", cbuff, pbuff);
#endif
if ( 0 == stricmp (cbuff, "show"))
{
strcpy (filename, pbuff);
status = show_pic (pbuff, speed, transition);
}
else if ( 0 == stricmp (cbuff, "speed"))
speed = atoi (pbuff);
else if ( 0 == stricmp (cbuff, "wait"))
{
delay_param = atoi (pbuff);
Delay ( delay_param );
}
#ifdef DEBUG
else if ( 0 == stricmp (cbuff, "debug"))
debug_level = atoi (pbuff);
#endif
else if ( 0 == stricmp (cbuff, "failat"))
{
failat = atoi (pbuff);
if ( failat < 1 )
failat = 1;
}
else if ( 0 == stricmp (cbuff, "index"))
{
rmap_index = atoi (pbuff);
if ( rmap_index < 2 )
rmap_index = 2;
if ( rmap_index > 32 )
rmap_index = 32;
}
else if ( 0 == stricmp (cbuff, "trans"))
{
if ( 0 == stricmp (pbuff, "zap"))
transition = DM_ZAP;
else if ( 0 == stricmp (pbuff, "twipe"))
transition = DM_TWIPE;
else if ( 0 == stricmp (pbuff, "bwipe"))
transition = DM_BWIPE;
else if ( 0 == stricmp (pbuff, "lwipe"))
transition = DM_LWIPE;
else if ( 0 == stricmp (pbuff, "rwipe"))
transition = DM_RWIPE;
else if ( 0 == stricmp (pbuff, "vblind"))
transition = DM_VBLIN;
else if ( 0 == stricmp (pbuff, "dissolve"))
transition = DM_DISSO;
else if ( 0 == stricmp (pbuff, "fade"))
transition = DM_DISSO;
else
transition = atoi (pbuff);
if ( transition < 0 )
transition = 0;
if ( transition > MAX_TRANSITION )
transition %= (MAX_TRANSITION + 1);
}
else if ( 0 == stricmp (cbuff, "front"))
pic_front ();
else if ( 0 == stricmp (cbuff, "back"))
pic_back ();
else if ( 0 == stricmp (cbuff, "close"))
close_pic_window ();
else if ( 0 == stricmp (cbuff, "exit"))
keep_going = 0;
else if ( 0 == stricmp (cbuff, "quit"))
keep_going = 0;
else
status = STS_UNKNOWN_CMD;
return (status);
}